#pragma once

#include <math.h>
#include <sndfile.h>
#include "FilterButterworth24db.h"
#ifndef GENERICPLUG
#define GENERICPLUG (99)
   #include "GenericPlugin.h"
#endif

class Sampler : public GenericPlugin
{
    protected:
        int channels;
    public:
        double speed, freq, tempo, offset, gain;
        float oscRad;
        float fInc;
        float pos;
        char filename[255];
        bool open;
        SF_INFO *sfinfo;
        SNDFILE *sndfile;
        float *data;
        CFilterButterworth24db filter;

        Sampler();

        void openFile();

        //implemented virtual functions..

        void isFree();
        void initMaster();
        void newSlave();
        void handleEvent( pluginEvent* event );
        void processBuffer( float *outputBuffer, unsigned long framesPerBuffer);
};

AUTO_REGISTER_GENERIC_PLUGIN(Sampler);
